package com.lnking.lnkingplace.service.impl;

import com.lnking.lnkingplace.mapper.RecordPlaceMapper;
import com.lnking.lnkingplace.model.entity.RecordPlace;
import com.lnking.lnkingplace.model.request.record.place.RecordPlaceAddRequest;
import com.lnking.lnkingplace.model.request.record.place.RecordPlaceUpdateRequest;
import com.lnking.lnkingplace.service.IRecordPlaceService;
import com.lnking.starter.mybatis.service.impl.CustomServiceImpl;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author zhangqt
 * @since 2022-08-19
 */
@Service
public class RecordPlaceServiceImpl extends CustomServiceImpl<RecordPlaceMapper, RecordPlace> implements IRecordPlaceService {

    @Override
    public void add(RecordPlaceAddRequest params) throws Exception {
        RecordPlace entity = new RecordPlace();
        BeanUtils.copyProperties(params, entity);
        entity.setCreateTime(LocalDateTime.now());
        getBaseMapper().insert(entity);
    }

    @Override
    public void update(RecordPlaceUpdateRequest params) {
        RecordPlace entity = new RecordPlace();
        BeanUtils.copyProperties(params, entity);
        getBaseMapper().updateById(entity);
    }
}
